-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[amplipi] Initial contribution of AmpliPi binding #10983
Conversation
Nice, following with interest! Once I get mine I might be able to help out also. |
FTR, some discussion on the right modelling is taking place at micro-nova/AmpliPi#54. |
Signed-off-by: Kai Kreuzer <[email protected]>
Signed-off-by: Kai Kreuzer <[email protected]>
Signed-off-by: Kai Kreuzer <[email protected]>
Signed-off-by: Kai Kreuzer <[email protected]>
Signed-off-by: Kai Kreuzer <[email protected]>
Signed-off-by: Kai Kreuzer <[email protected]>
Signed-off-by: Kai Kreuzer <[email protected]>
Signed-off-by: Kai Kreuzer <[email protected]>
Signed-off-by: Kai Kreuzer <[email protected]>
Signed-off-by: Kai Kreuzer <[email protected]>
@openhab/add-ons-maintainers This is now ready for review. The implementation contains the main features that make sense to have. Future PRs will add further functionality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you add the generated files by intention?
There are some checkstyle warnings left.
super(thing); | ||
this.httpClient = httpClient; | ||
this.gson = new Gson(); | ||
id = Integer.valueOf(thing.getConfiguration().get(AmpliPiBindingConstants.CFG_PARAM_ID).toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be set in initialize() to be updated on configuration updates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I have now removed the field completely and use a method instead. This way, we can be sure that it's always the latest value that is used.
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, | ||
"AmpliPi request failed: " + e.getMessage()); | ||
} catch (ExecutionException e) { | ||
logger.error("HTTP request to AmpliPi failed: {}.", e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem resonable to log to error when the network fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's a network issue, we run into the TimeoutException
which is caught above.
I am not exactly sure in which situations an ExecutionException
exactly occurs - that's why I rather considered it a bug situation as long as it isn't better handled. Do you happen to know when we can expect the ExecutionException
from the httpClient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting question. I always assumed that a ExecutionException
can be caused by a network failure. I did a quick search and couldn't find any official documentation, but I found some stack traces showing this (in an OH context):
Caused by: java.util.concurrent.ExecutionException: java.net.ConnectException: Connection refused
at org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118)
...
I would handle this as a network failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure. A "Connection refused" means that the network is available, but that the contacted device did not accept the request at all - meaning that the request was invalid (e.g. by using a wrong port), so it might be due to a bug in the code.
But it's ok for me to treat it like a network issue - users will complain, if their things go OFFLINE for an ununderstood reason anyhow. I've changed the code accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or the host is available, but the service is down. I think you can't clearly differentiate between temprorary or fatal errors here.
...enhab.binding.amplipi/src/main/java/org/openhab/binding/amplipi/internal/AmpliPiHandler.java
Outdated
Show resolved
Hide resolved
...b.binding.amplipi/src/main/java/org/openhab/binding/amplipi/internal/AmpliPiZoneHandler.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Kai Kreuzer <[email protected]>
Yes, absolutely. The code has actually be manually adapted after generation and the generator is configured to not overwrite existing files. I thought I leave the maven plugin in the pom, so that it is easier in future to generate additional model classes when the Swagger file is extended by new features. |
Signed-off-by: Kai Kreuzer <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The build leaves an untracked file: |
Yes. I have created #11081 for it. |
* Initial contribution of AmpliPi binding Signed-off-by: Kai Kreuzer <[email protected]> * change http client from cxf jax-rs to Jetty Signed-off-by: Kai Kreuzer <[email protected]> * applied spotless Signed-off-by: Kai Kreuzer <[email protected]> * Remove Jackson dependency Signed-off-by: Kai Kreuzer <[email protected]> * Add support for input handling Signed-off-by: Kai Kreuzer <[email protected]> * Clean up, improvements and documentation Signed-off-by: Kai Kreuzer <[email protected]> * Remove unused password from configuration class Signed-off-by: Kai Kreuzer <[email protected]> * Remove example properties file Signed-off-by: Kai Kreuzer <[email protected]> * revert change in .gitignore Signed-off-by: Kai Kreuzer <[email protected]> * Update README Signed-off-by: Kai Kreuzer <[email protected]> * Address review feedback Signed-off-by: Kai Kreuzer <[email protected]> * Handle ExecutionException as network error Signed-off-by: Kai Kreuzer <[email protected]>
* Initial contribution of AmpliPi binding Signed-off-by: Kai Kreuzer <[email protected]> * change http client from cxf jax-rs to Jetty Signed-off-by: Kai Kreuzer <[email protected]> * applied spotless Signed-off-by: Kai Kreuzer <[email protected]> * Remove Jackson dependency Signed-off-by: Kai Kreuzer <[email protected]> * Add support for input handling Signed-off-by: Kai Kreuzer <[email protected]> * Clean up, improvements and documentation Signed-off-by: Kai Kreuzer <[email protected]> * Remove unused password from configuration class Signed-off-by: Kai Kreuzer <[email protected]> * Remove example properties file Signed-off-by: Kai Kreuzer <[email protected]> * revert change in .gitignore Signed-off-by: Kai Kreuzer <[email protected]> * Update README Signed-off-by: Kai Kreuzer <[email protected]> * Address review feedback Signed-off-by: Kai Kreuzer <[email protected]> * Handle ExecutionException as network error Signed-off-by: Kai Kreuzer <[email protected]>
* Initial contribution of AmpliPi binding Signed-off-by: Kai Kreuzer <[email protected]> * change http client from cxf jax-rs to Jetty Signed-off-by: Kai Kreuzer <[email protected]> * applied spotless Signed-off-by: Kai Kreuzer <[email protected]> * Remove Jackson dependency Signed-off-by: Kai Kreuzer <[email protected]> * Add support for input handling Signed-off-by: Kai Kreuzer <[email protected]> * Clean up, improvements and documentation Signed-off-by: Kai Kreuzer <[email protected]> * Remove unused password from configuration class Signed-off-by: Kai Kreuzer <[email protected]> * Remove example properties file Signed-off-by: Kai Kreuzer <[email protected]> * revert change in .gitignore Signed-off-by: Kai Kreuzer <[email protected]> * Update README Signed-off-by: Kai Kreuzer <[email protected]> * Address review feedback Signed-off-by: Kai Kreuzer <[email protected]> * Handle ExecutionException as network error Signed-off-by: Kai Kreuzer <[email protected]> Signed-off-by: Dave J Schoepel <[email protected]>
* Initial contribution of AmpliPi binding Signed-off-by: Kai Kreuzer <[email protected]> * change http client from cxf jax-rs to Jetty Signed-off-by: Kai Kreuzer <[email protected]> * applied spotless Signed-off-by: Kai Kreuzer <[email protected]> * Remove Jackson dependency Signed-off-by: Kai Kreuzer <[email protected]> * Add support for input handling Signed-off-by: Kai Kreuzer <[email protected]> * Clean up, improvements and documentation Signed-off-by: Kai Kreuzer <[email protected]> * Remove unused password from configuration class Signed-off-by: Kai Kreuzer <[email protected]> * Remove example properties file Signed-off-by: Kai Kreuzer <[email protected]> * revert change in .gitignore Signed-off-by: Kai Kreuzer <[email protected]> * Update README Signed-off-by: Kai Kreuzer <[email protected]> * Address review feedback Signed-off-by: Kai Kreuzer <[email protected]> * Handle ExecutionException as network error Signed-off-by: Kai Kreuzer <[email protected]>
This binding supports the AmpliPi home audio system - see https://www.micro-nova.com/amplipi.
Signed-off-by: Kai Kreuzer [email protected]